<!DOCTYPE html>
<html>
<head>
  <title>称重记录表添加</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="bootstrap4/css/bootstrap.min.css">
  <link rel="stylesheet" href="css2/style2.css"> 
  <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/lib/jquery.js"></script>
  <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
  <script src="js2/my.js"></script>
</head>

<script type="text/javascript">
$(function(){
	$("#formID").validate({
        rules: {
            "equmtId": {
                required: true
            },
            "orgId": {
                required: true
            },
            "weightDate": {
                required: true
            },
            "weightCount": {
                required: true
            },
            "weightData": {
                required: true
            },
            "weightSeq": {
                required: true
            },
            "weightTime": {
                required: true
            },
            "weightCar": {
                required: true
            },
            "weightOrg": {
                required: true
            },
            "weightGood": {
                required: true
            },
            "weightMweight": {
                required: true
            },
            "weightPweight": {
                required: true
            },
            "weightStatus": {
                required: true
            }
        },
        messages:{
            "equmtId": {
                required: "设备id不能为空"
            },
            "orgId": {
                required: "机构id不能为空"
            },
            "weightDate": {
                required: "称重时间不能为空"
            },
            "weightCount": {
                required: "重量不能为空"
            },
            "weightData": {
                required: "称重记录数据不能为空"
            },
            "weightSeq": {
                required: "序号不能为空"
            },
            "weightTime": {
                required: "年月日时分秒不能为空"
            },
            "weightCar": {
                required: "车号不能为空"
            },
            "weightOrg": {
                required: "单位号不能为空"
            },
            "weightGood": {
                required: "货号不能为空"
            },
            "weightMweight": {
                required: "毛重不能为空"
            },
            "weightPweight": {
                required: "皮重不能为空"
            },
            "weightStatus": {
                required: "状态不能为空"
            }
        },
        submitHandler:function(form){
        	$.ajax({
        		type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "saveWeightInfo" ,//url
                data: $('#formID').serialize(),
                success: function (result) {
                    console.log(result);//打印服务端返回的数据(调试用)
                    if (result.code == 200) {
                        if(confirm(result.msg+'是否继续？？'))
                        {   
                        	 window.location.href = "addWeightInfo";
                        }
                        else
                        {  
                        	 window.location.href = "queryForWeightInfoList";
                        }
                    }
                    else{                	
                    	alert(result.msg);
                    }
                     
                },
                error : function() {
                    alert("异常！");
                }
            });
        },
        //自定义错误样式
        errorClass:"text-danger",
        //未通过验证,进行高亮处理或其他处理；
        highlight:function(input){
            $(input).closest(".form-group").addClass("has-error");
        },
        //通过验证,清除高亮效果或其他处理；
        unhighlight:function(input){
            $(input).closest(".form-group").removeClass("has-error");
        }
	});
});

</script>
<body>
<div class="header-area" id="headerArea">
   <div class="container h-100 d-flex align-items-center justify-content-between">
 
     <div class="logo-wrapper">
     <a th:href="@{/queryForWeightInfoList}"> 返回 </a>
	 </div>
     <!-- Search Form-->
     <div class="top-search-form">
      	 称重记录表添加
     </div>
     <div  id="suhaNavbarToggler"><span></span><span></span><span></span></div>
   </div>
 </div>

<div class="container mt60">
  <form id="formID"  >
  	<input type="hidden" name="weightId" th:value="${weightInfoVO?.weightId}" /> 
    <div class="form-group">
       <div class="single-payment-method"> 
       		<img class="mb-3" src="img/bg-img/9.jpeg"   width="100%"alt="">
       </div>
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="equmtId" class="fl" >设备id:</label>
      <input type="text" class="form-control" id="equmtId" placeholder="请填写设备id" 
      name="equmtId"
      th:value="${weightInfoVO?.equmtId}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="orgId" class="fl" >机构id:</label>
      <input type="text" class="form-control" id="orgId" placeholder="请填写机构id" 
      name="orgId"
      th:value="${weightInfoVO?.orgId}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="weightDate" class="fl" >称重时间:</label>
      <input type="text" class="form-control" id="weightDate" placeholder="请填写称重时间" 
      name="weightDate"
      th:value="${weightInfoVO?.weightDate}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="weightCount" class="fl" >重量:</label>
      <input type="text" class="form-control" id="weightCount" placeholder="请填写重量" 
      name="weightCount"
      th:value="${weightInfoVO?.weightCount}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="weightData" class="fl" >称重记录数据:</label>
      <input type="text" class="form-control" id="weightData" placeholder="请填写称重记录数据" 
      name="weightData"
      th:value="${weightInfoVO?.weightData}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="weightSeq" class="fl" >序号:</label>
      <input type="text" class="form-control" id="weightSeq" placeholder="请填写序号" 
      name="weightSeq"
      th:value="${weightInfoVO?.weightSeq}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="weightTime" class="fl" >年月日时分秒:</label>
      <input type="text" class="form-control" id="weightTime" placeholder="请填写年月日时分秒" 
      name="weightTime"
      th:value="${weightInfoVO?.weightTime}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="weightCar" class="fl" >车号:</label>
      <input type="text" class="form-control" id="weightCar" placeholder="请填写车号" 
      name="weightCar"
      th:value="${weightInfoVO?.weightCar}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="weightOrg" class="fl" >单位号:</label>
      <input type="text" class="form-control" id="weightOrg" placeholder="请填写单位号" 
      name="weightOrg"
      th:value="${weightInfoVO?.weightOrg}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="weightGood" class="fl" >货号:</label>
      <input type="text" class="form-control" id="weightGood" placeholder="请填写货号" 
      name="weightGood"
      th:value="${weightInfoVO?.weightGood}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="weightMweight" class="fl" >毛重:</label>
      <input type="text" class="form-control" id="weightMweight" placeholder="请填写毛重" 
      name="weightMweight"
      th:value="${weightInfoVO?.weightMweight}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="weightPweight" class="fl" >皮重:</label>
      <input type="text" class="form-control" id="weightPweight" placeholder="请填写皮重" 
      name="weightPweight"
      th:value="${weightInfoVO?.weightPweight}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="weightStatus" class="fl" >状态:</label>
      <input type="text" class="form-control" id="weightStatus" placeholder="请填写状态" 
      name="weightStatus"
      th:value="${weightInfoVO?.weightStatus}" >
    </div>
     <button type="submit" class="btn btn-primary btn-block" >提交</button>
  </form>
 
</div>

</body>
</html>
